import { Pipe, PipeTransform } from '@angular/core';
import { CartItem } from 'src/app/shared/ngrx/cart-store/cart.reducer';

@Pipe({
  name: 'totalProductsMoney',
})
export class TotalProductsMoneyPipe implements PipeTransform {
  transform(cartList: CartItem[]): number {
    let total = 0;
    cartList.forEach((item) => {
      if (item.selected) {
        total += item.count * item.price;
      }
    });
    return total;
  }
}
